package com.hdsx.restful.glzt.roadline.cfld.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.esri.arcgis.geometry.IGeometry;
import com.hdsx.ao.base.BaseOpearte;
import com.hdsx.ao.util.GemotryUtil;
import com.hdsx.restful.glzt.roadline.cfld.bean.Cfld;
import com.hdsx.restful.glzt.roadline.cfld.mapper.CfldMapper;
import com.hdsx.restful.glzt.roadline.cfld.service.CfldService;

@Service
public class CfldServiceImpl extends BaseOpearte<Cfld>  implements CfldService {

	public CfldServiceImpl() {
		super("GIS_CFLD");
	}

	@Resource
	private CfldMapper cfldMapper;

	@Override
	public int queryCountByParameter(String lxdm) {
		Map<String,String> map=new HashMap<String, String>();
		map.put("lxdm",lxdm);
		return cfldMapper.queryCountByParameter(map);
	}
	
	@Override
	public List<Cfld> queryByParameter(String lxdm, int begin, int end) {
		
		Map<String,Object> parameter=new HashMap<String,Object>();
		parameter.put("begin",begin);
		parameter.put("end", end);
		parameter.put("lxdm",lxdm);
		List<Cfld> lists=cfldMapper.queryByParameter(parameter);
		for(Cfld cfld:lists){
			cfld.setShape(selectShape("ID= '"+cfld.getId()+"'"));
		}
		return lists;
	}
	
	@Override
	public String queryCfldString(String id) {
	   IGeometry shape=selectShape("ID= '"+id+"'");
	   return GemotryUtil.generateLineString(shape);
	}

}
